package soundwave.com.demo.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import soundwave.com.demo.R;

/**
 * Created by xu on 2017/4/5.
 */

public class Retrieve_password extends Activity {
    private TextView back;
    private EditText phone;
    private Button send_code;
    private EditText code;
    private Button retrieve;
    private String phone_number, code_number;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.retrieve_password);
        initView();
        send_code.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                phone_number = phone.getText().toString();
                if (phone_number.length()<11){
                    Toast.makeText(Retrieve_password.this, "手机号码格式不对", Toast.LENGTH_SHORT).show();
                }else {
                    if (phone_number.equals("")){
                        Toast.makeText(Retrieve_password.this, "手机号码不能为空", Toast.LENGTH_SHORT).show();
                    }else {
                        Toast.makeText(Retrieve_password.this, "发送成功", Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });
        retrieve.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                phone_number=phone.getText().toString();
                code_number=code.getText().toString();
                if (phone_number.equals("")){
                    Toast.makeText(Retrieve_password.this, "手机号码不能为空", Toast.LENGTH_SHORT).show();
                }else if (phone_number.length()<11){
                    Toast.makeText(Retrieve_password.this, "手机号码格式不对", Toast.LENGTH_SHORT).show();
                }else {
                    if (code_number.equals("")){
                        Toast.makeText(Retrieve_password.this, "验证码不能为空", Toast.LENGTH_SHORT).show();
                    }else {
                        Toast.makeText(Retrieve_password.this, "校样成功", Toast.LENGTH_SHORT).show();
                        startActivity(new Intent(Retrieve_password.this,Modify_password2.class));
                        finish();
                    }
                }
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });



    }

    private void initView() {
        back = (TextView) findViewById(R.id.back);
        phone = (EditText) findViewById(R.id.phone);
        send_code = (Button) findViewById(R.id.send_code);
        code = (EditText) findViewById(R.id.code);
        retrieve = (Button) findViewById(R.id.retrieve);


    }


}

